<template>
  <div>
    <div class="form_inp">
      <el-dialog title="编辑权限" :visible.sync="permissionShow">
        <el-form :model="permissionForm">
          <!-- 权限名称 -->
          <el-form-item label="权限名称" label-width="100px">
            <el-input v-model="permissionForm.name" />
          </el-form-item>

          <!-- 权限标识 -->
          <el-form-item label="权限标识" label-width="100px">
            <el-input v-model="permissionForm.code" />
          </el-form-item>

          <!-- 权限描述 -->
          <el-form-item label="权限描述" label-width="100px">
            <el-input v-model="permissionForm.description" />
          </el-form-item>

          <!-- 企业可见 -->
          <el-form-item label="企业可见" label-width="100px">
            <el-switch
              v-model="permissionForm.valueSwitch"
              active-color="#13ce66"
              inactive-color="#ff4949"
            />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="permissionShow = false">取 消</el-button>
          <el-button type="primary" @click="submit">确 定</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script lang="js">
import {
  // 添加权限点
  getAddPermissionApi
  // 获取所有权限点
  // getAllPermissionApi
} from '@/api/permission.js'
export default {
  props: {
    currentData: Object
  }
  name: 'ComponentPermissionShow',
  data() {
    return {
      // 添加列表
      permissionForm: {
        name: '', // 权限名称
        code: '', // 权限标识
        description: '', // 权限描述
        valueSwitch: true // 图标开关
      },
      permissionShow: false // 弹窗

    }
  },
  mounted() {
    // this.getAllPermission()
  },
  methods: {
    // 确定按钮
    async submit() {
      const res = await getAddPermissionApi(this.permissionForm)
      this.$emit('upDataList', res.data)
      console.log(res)
      this.permissionShow = false
      this.permissionForm = {
        name: '', // 权限名称
        code: '', // 权限标识
        description: '', // 权限描述
        valueSwitch: true // 图标开关
      }
    }

  }

}
</script>

<style lang="scss" scope>
.form_inp {
  .el-input {
    width: 500px;
  }
  .el-dialog__header .el-icon-close:before {
    color: #979aa0;
  }
}
</style>
